﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Qcy.Jshj.Web.Helpers;
using Webdiyer.WebControls.Mvc;

namespace Qcy.Jshj.Web.Models
{
    public class ProductsModel
    {
        /// <summary>
        /// 当前大分类
        /// </summary>
        public Qcy.Jshj.Web.Helpers.CompanyInfo Category { get; set; }
        /// <summary>
        /// 当前子分类
        /// </summary>
        public Qcy.Jshj.Web.Helpers.CompanyInfo SubCategory { get; set; }
        /// <summary>
        /// 所有子分类
        /// </summary>
        public IEnumerable<Qcy.Jshj.Web.Helpers.CompanyInfo> SubCategories { get; set; }
        /// <summary>
        /// 分类下的所有产品
        /// </summary>
        public PagedList<Qcy.Jshj.Web.Helpers.Product> Products { get; set; }


        public ProductsModel(int id, int cate, int page, int pageSize)
        {
            Category = DataHelper.ProductCategory(id);
            SubCategory = DataHelper.ProductCategory(cate);
            SubCategories = DataHelper.GetProductCategories(id);
            Products = DataHelper.GetProducts(id, cate).AsQueryable().ToPagedList(page, pageSize); ;
        }
    }
}